package br.com.gtacomputadores.control.dao;

import br.com.gtacomputadores.control.model.Agenda;
import br.com.gtacomputadores.control.utils.HibernateUtil;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author Jeandro
 */
public class AgendaDAOHibernate implements AgendaDAO {

    @Override
    public void save(Agenda agenda) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        Transaction t = session.beginTransaction();

        session.save(agenda);
        session.flush();
        t.commit();

    }

    @Override
    public Agenda getAgenda(long codigo) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<Agenda> list() {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        Transaction t = session.beginTransaction();
        List lista = session.createQuery("from Agenda").list();
        t.commit();
        return lista;
    }
    

    @Override
    public void remove(Agenda agenda) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void update(Agenda agenda) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

}
